package com.google.code.alpaca.prototype.server;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import net.customware.gwt.dispatch.server.ActionHandlerRegistry;

import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class ActionHandlerClearFilter implements Filter {

	@Inject
	private ActionHandlerRegistry registry;

	@Override
	public void init(FilterConfig aFilterConfig) throws ServletException {
	}

	@Override
	public void doFilter(ServletRequest aRequest, ServletResponse aResponse,
			FilterChain aChain) throws IOException, ServletException {
		registry.clearHandlers();
		aChain.doFilter(aRequest, aResponse);
	}

	@Override
	public void destroy() {
	}

}
